package com.yoyo.itravel.dao;

import com.yoyo.itravel.bean.SightTicketStock;
import com.yoyo.itravel.constants.BaseSqlProviderConstant;
import com.yoyo.itravel.sql_provider.BaseSqlProvider;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.sql.SQLException;
import java.util.List;

/**
 * @Description 景点门票库存相关操作接口【持久层】
 * @Author HZX
 * @Version 1.0
 * @Date 2020/6/26 11:31
 */
@Repository
public interface ISightTicketStockDao {

	/**
	 * @Description 插入景点门票信息
	 *
	 * @param sightStock
	 * @return Integer
	 */
    @InsertProvider(type = BaseSqlProvider.class, method = BaseSqlProviderConstant.INSERT)
	Integer insert(SightTicketStock sightStock) throws SQLException;

    /**
	 * @Description 通过景点门票库存id修改景点库存信息
	 *
	 * @Param sightStock
	 * @Return Integer
	 */
	@UpdateProvider(type = BaseSqlProvider.class, method = BaseSqlProviderConstant.UPDATE_BY_ID)
	Integer updateById(SightTicketStock sightStock) throws SQLException;

	// /**
	//  * @Description
	//  *
	//  * @Param ticketStockId
	//  * @Param nowStockNum
	//  * @Return java.lang.Integer
	//  */
	// @Update("update tb_sight_ticket_stock set nowStockNum=#{nowStockNum} where detailTypeId=#{detailTypeId} and date=#{date}")
	// Integer ByDetailTypeIdAndDate(@Param("ticketStockId") String detailTypeId, @Param("date") Date date) throws SQLException;

	/**
	 * @Description 根据条件得到对应的景点门票库存【可以用于：通过具体门票类型id和日期获得当天景点门票库存数量】
	 *
	 * @param sightStock
	 * @return Object
	 */
	@SelectProvider(type = BaseSqlProvider.class, method = BaseSqlProviderConstant.SELETE)
	List<SightTicketStock> selectByCondition(SightTicketStock sightStock) throws SQLException;

	@Select("select * from tb_sight_ticket_stock where detailTypeId=#{id}")
	List<SightTicketStock> select(String id) throws SQLException;

	/**
	 * @Description 通过景点门票库存id删除景点门票库存信息
	 *
	 * @Param ticketStockId
	 * @Return Integer
	 */
	@Delete("delete from tb_sight_ticket_stock where ticketStockId=#{ticketStockId}")
    Integer deleteById(String ticketStockId) throws SQLException;

	/**
	 * @Description 根据条件得到对应的景点门票库存
	 *
	 * @param ticketStockId
	 * @return com.yoyo.itravel.bean.Country
	 */
	@Select("select * from tb_sight_ticket_stock where ticketStockId=#{ticketStockId}")
	SightTicketStock selectById(String ticketStockId) throws SQLException;

	/**
	 * @Description 得到所有的景点门票库存信息
	 *
	 * @param
	 * @return java.util.List<com.yoyo.itravel.bean.Country>
	 */
	@Select("select * from tb_sight_ticket_stock")
	List<SightTicketStock> selectAll() throws SQLException;

}
